// pages/viewer/viewer.js
const db = wx.cloud.database();
const _ = db.command
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    room: {},
    mode:0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let room = {}
    room = app.globalData.room
    this.setData({
      room,
      mode:room.mode
    })
    this.get_watch()
  },
  get_watch() {
    let room = this.data.room
    let that = this
    let isok = 0
    console.log("1111111",room);
    const watcher = db.collection('room').doc(room._id).watch({
      onChange: (snapshot) => {
        console.log(snapshot);
        room = snapshot.docs[0]
        that.setData({
          room
        })
      },
      onError:(err=>{console.log(err);})
    })

  },
  onReady: function () {

  },

  onUnload: function () {

  },

})